<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>登录页</title>

	<script src="js/jquery-3.6.0.min.js"></script>
	<script src="js/axios-0.18.0.js"></script>
</head>
<body>
<form action="login.do" id="form1">
	账号:<input type="text" name="username" id="username"> <br>
	密码:<input type="text" name="password" id="password"> <br>
	身份:<select name="sf">
			<option value="cjgly">超级管理员</option>
			<option value="hjvip">黄金VIP</option>
			<option value="gb">贵宾</option>
			<option value="ptyh">普通用户</option>
		</select> <br>

	<input type="button" value="登录" onclick="func()">
</form>
</body>

<script>
	// jquery的页面加载函数
	$(function(){
		let str = window.location.search;
		if(str != ""){
			alert("账号或密码错误!");
		}
	});



	function func() {
		let usernameRegex = /^[a-z]\d{6,20}$/;
		let usernameValue = $("#username").val();

		if(!usernameRegex.test(usernameValue)){
			alert("账号格式不对");
			return;
		}

		let passwordRegex = /^\d{6,20}$/;
		let passwordValue = $("#password").val();

		if(!passwordRegex.test(passwordValue)){
			alert("密码格式不对");
			return;
		}


		$("#form1").submit();
	}
</script>

</html>